// ReportListCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "mfc_test2.h"
#include "ReportListCtrl.h"


// CReportListCtrl

IMPLEMENT_DYNAMIC(CReportListCtrl, CListCtrl)

CReportListCtrl::CReportListCtrl()
{

}

CReportListCtrl::~CReportListCtrl()
{
}


BEGIN_MESSAGE_MAP(CReportListCtrl, CListCtrl)
  ON_NOTIFY(HDN_GETDISPINFOA, 0, &CReportListCtrl::OnHdnGetdispinfo)
  ON_NOTIFY(HDN_GETDISPINFOW, 0, &CReportListCtrl::OnHdnGetdispinfo)
  ON_NOTIFY_REFLECT(LVN_GETINFOTIP, &CReportListCtrl::OnLvnGetInfoTip)
END_MESSAGE_MAP()



// CReportListCtrl message handlers



void CReportListCtrl::OnHdnGetdispinfo(NMHDR *pNMHDR, LRESULT *pResult)
{
  LPNMHDDISPINFO pDispInfo = reinterpret_cast<LPNMHDDISPINFO>(pNMHDR);
  // TODO: Add your control notification handler code here

 //// LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;

 // //Create a pointer to the item
 // LV_ITEM* pItem= &(pDispInfo)->item;

 // //Which item number?
 // int itemid = pItem->iItem;

  int itemid = pDispInfo->iItem;

  //Do the list need text information?
  if (pDispInfo->mask & LVIF_TEXT)
  {
    CString text;

    ////Which column?
    //if(pDispInfo->lParam->iSubItem == 0)
    //{
    //  //Text is name
    //  text = m_database[itemid].m_name;
    //}
    //else if (pItem->iSubItem == 1)
    //{
    //  //Text is slogan
    //  text = m_database[itemid].m_slogan;
    //}

    //Copy the text to the LV_ITEM structure
    //Maximum number of characters is in pItem->cchTextMax
    lstrcpyn(pDispInfo->pszText, text, pDispInfo->cchTextMax);
  }

  *pResult = 0;
}

void CReportListCtrl::OnLvnGetInfoTip(NMHDR *pNMHDR, LRESULT *pResult)
{
  LPNMLVGETINFOTIP pGetInfoTip = reinterpret_cast<LPNMLVGETINFOTIP>(pNMHDR);
  // TODO: Add your control notification handler code here
  *pResult = 0;
}
void CReportListCtrl::PreSubclassWindow()
{
  // TODO: Add your specialized code here and/or call the base class
  InsertColumn(0, _T("Name"), LVCFMT_LEFT, 130);
  InsertColumn(1, _T("Slogan"), LVCFMT_LEFT, 200);

  CListCtrl::PreSubclassWindow();
}
